import { BasicColumn, FormSchema } from '@/components/table';
import { getDictTreeList } from '../data/dict.api';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '字典名称',
    dataIndex: 'dicDataTitle',
    width: 200,
  },
  {
    title: '字典值',
    dataIndex: 'dicDataValue',
    width: 200,
  },
  {
    title: '排序值',
    dataIndex: 'sortOrder',
    width: 100,
  },
  {
    title: '状态',
    dataIndex: 'state',
    width: 100,
    dictData: [
      { label: '启用', value: 1 },
      { label: '未启用', value: 0 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'dicDataTitle',
    label: '字典项',
    component: 'Input',
    colProps: { span: 3 },
  },
  {
    field: 'dicDataValue',
    label: '字典值',
    component: 'Input',
    colProps: { span: 3 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '分类编码',
    field: 'dicType',
    component: 'Input',
    required: true,
  },
  {
    label: '分类名称',
    field: 'dicTitle',
    component: 'Input',
    required: true,
  },
];

export const dictDataFormSchema: FormSchema[] = [
  {
    label: '字典分类',
    field: 'dictId',
    component: 'ApiSelect',
    required: true,
    componentProps: {
      api: getDictTreeList,
      labelField: 'dicTitle',
      valueField: 'dictId',
    },
  },
  {
    label: '字典项标题',
    field: 'dicDataTitle',
    component: 'Input',
    required: true,
  },
  {
    label: '字典项值',
    field: 'dicDataValue',
    component: 'Input',
    required: true,
  },
  {
    label: '状态',
    field: 'state',
    component: 'Select',
    required: true,
    componentProps: {
      options: [
        { label: '启用', value: 1 },
        { label: '不启用', value: 2 },
      ],
    },
  },
  {
    label: '排序值',
    field: 'sortOrder',
    component: 'InputNumber',
    required: true,
  },
];
